(defun php-mkdir()
  (interactive)
  (insert "<?php
mkdir(\"/path/to/my/dir\", 0700);
?>



<?php
// Desired folder structure
$structure = './depth1/depth2/depth3/';

// To create the nested structure, the $recursive parameter 
// to mkdir() must be specified.

if (!mkdir($structure, 0, true)) {
    die('Failed to create folders...');
}
?>
")
  )

(defun php-wscript()
  (interactive)
  (insert " <?php
    $shell = new COM(\"WScript.Shell\");
    $shell->popup(\"Now launching IE...\", 30, \"Executing COM code\", 64);

    $browser = new COM(\"InternetExplorer.Application\");
    $browser->navigate(\"about:blank\");

    $network = new COM(\"WScript.Network\");
    $sys = $shell->environment('SYSTEM');
    $CPU = $sys->item('PROCESSOR_IDENTIFIER');

    $browser->Visible = true;
    $browser->Width = 700;
    $browser->height = 380;
    $browser->resizable = false;
    $browser->document->title = \"Hello, PHP!\";
    $browser->document->body->innerhtml = <<<EOT

    <html>
    <body>
    <h1 id=\"title\">COM and PHP</h1>
    <p id=\"maintext\">
    This is a test of COM and PHP.<br /><br />
    We can instantiate lots of different objects with COM, and read in their variables as if they were normal PHP objects.<br /><br />
    For example, you are currently logged on as {$network->username} on computer {$network->computername}, a $CPU.<br /><br /></p>
    <input type=\"text\" id=\"mytxt\" size=\"80\"/>
    </body>
    </html>
EOT;
    $browser->document->all->title->style->csstext = \"font: 26px Verdana; color: blue\";
    $browser->document->all->maintext->style->csstext = \"font: 12px Verdana; color: #333333\";
    $browser->document->all->mytxt->focus();

    $shell->appactivate(\"Internet Explorer\");
    $shell->SendKeys(\"We have complete control over the IE window\");

    $shell = null;
    $browser = null;
    $network = null;
?> ")
  )

(defun php-text-replace()
  (interactive)
  (insert "<?php
set_time_limit(0);
function recurDir($dir,$txt='',$new='') {
    if(is_dir($dir)) {
        if($handle = opendir($dir)) {
            while(false !== ($file = readdir($handle))) {
                if(is_dir($dir.'/'.$file)) {
                    if($file != '.' && $file != '..') {
                        $path = $dir.'/'.$file;
                        recurDir($path,$txt,$new);
                    }
                }else{
                    $path = $dir.'/'.$file;
                    change($path,$txt,$new);
                }
            }
        }
        closedir($handle);
    }
}
function change($dir,$txt='',$new=''){
    $f = file_get_contents($dir);
    if(strpos($f,$txt)){
        $f = str_ireplace($txt,$new,$f);
        file_put_contents($dir,$f);
        echo $dir.'<br />';
    }
 
}
recurDir('txt','[!--empirenews.page--]');")
  )

(defun php-functionName()
  ""
  (interactive)
  (insert "__METHOD__ or __FUNCTION__")
  )


(defun php-string-split-by-space()
  ""
  (interactive)
  (insert "
<?php
// Example 1
$pizza  = \"piece1 piece2 piece3 piece4 piece5 piece6\";
$pieces = explode(\" \", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2

// Example 2
$data = \"foo:*:1023:1000::/home/foo:/bin/sh\";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(\":\", $data);
echo $user; // foo
echo $pass; // *

?>
")
  )
